/*
 * Copyright (C) 2016 venshine.cn@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.avcdata.aoscustommade.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.avcdata.aoscustommade.R;
import com.wx.wheelview.adapter.BaseWheelAdapter;

/**
 * 滚动选择适配器
 *
 */
public class MyWheelAdapter extends BaseWheelAdapter<String> {

    private Context mContext;
//    protected List<T> data;

    public MyWheelAdapter(Context context) {
        mContext = context;
    }

//    public void setMySelfData(List<T> data) {
//        this.data = data;
//    }
//
//    @SuppressWarnings("deprecation")
//    public void addData(List<T> data) {
//        if (this.data == null) {
//            this.data = data;
//        } else {
//            this.data.addAll(data);
//        }
//        notifyDataSetChanged();
//    }
//
//    @SuppressWarnings("deprecation")
//    public void addData(T bean) {
//        if (this.data != null) {
//            this.data.add(bean);
//            notifyDataSetChanged();
//        }
//    }
//
//
//    private int count = -1;
//    public void setCount(int i) {
//        count = i;
//    }
//
//    @SuppressWarnings("deprecation")
//    public void clear() {
//        if (this.data == null) {
//            return;
//        } else {
//            this.data.clear();
//        }
//        notifyDataSetChanged();
//    }

//    @Override
//    public int getCount() {
//        if (data == null) {
//            return 0;
//        }
//        int getCount = data.size();
//        return count == -1 ? getCount : Math.min(getCount, count);
//    }

    @Override
    protected View bindView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_text, null);
            viewHolder.textView = (TextView) convertView.findViewById(R.id.item_name);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.textView.setText(mList.get(position));
        return convertView;
    }

    private class ViewHolder {
        TextView textView;
    }

}
